﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Configuration.Provider;
using System.Data.Odbc;
using System.Data.SqlClient;

public partial class Management_authManage : System.Web.UI.Page
{
    string[] rolesArray;

    public void Page_Load(object sender, EventArgs args)
    {
        if (!IsPostBack)
        {
            // Bind roles to ListBox.

            rolesArray = Roles.GetAllRoles();
            RolesListBox.DataSource = rolesArray;
            RolesListBox.DataBind();
        }
    }

    public void DeleteRole_OnClick(object sender, EventArgs args)
    {
        string delRole = "";
        try
        {
            delRole = RolesListBox.SelectedItem.Value;

            Roles.DeleteRole(delRole);

            Msg.Text = "Role '" + Server.HtmlEncode(delRole) + "' deleted.";


            // Re-bind roles to ListBox.

            rolesArray = Roles.GetAllRoles();
            RolesListBox.DataSource = rolesArray;
            RolesListBox.DataBind();
        }
        catch
        {
            Msg.Text = "Role '" + Server.HtmlEncode(delRole) + "' <u>not</u> deleted.";
        }
    }
}